package com.yiqi.zhiyuan.feature.login.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.UserInfoBo;
import com.yiqi.zhiyuan.entity.dto.RegisterDTO;
import com.yiqi.zhiyuan.feature.login.contract.ResetContract;
import com.yiqi.zhiyuan.feature.login.dependencies.reset.DaggerResetModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.UserApi;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class ResetModel implements ResetContract.Model {
    @Inject
    UserApi api;

    public ResetModel() {
        DaggerResetModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }

    @Override
    public Observable<String> doSendCode(String phone,int type) {
        return api.sendCode(phone,type).compose(RxDataProcessFactory.<String>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<UserInfoBo> doResetPwd(RegisterDTO registerDTO) {
        return api.resetPwd(registerDTO).compose(RxDataProcessFactory.<UserInfoBo>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<UserInfoBo> doEditPhone(RegisterDTO registerDTO) {
        return api.updatePhone(registerDTO).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }


}

